-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: create address input #362
Conversation
Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:
|
…ryconfig into address-input-v2
src/form/v2/person/index.ts
Outdated
@@ -195,6 +218,55 @@ const getIdFields = (person: string): FieldConfig[] => [ | |||
} | |||
] | |||
|
|||
const getAddressOrSameAsMotherFields = (person: string): FieldConfig[] => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we have a tighter type for person?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Some suggestions
src/form/v2/person/index.ts
Outdated
@@ -291,7 +363,7 @@ export const getInformantFields = (person: string): FieldConfig[] => [ | |||
}, | |||
options: { fontVariant: 'h2' } | |||
}, | |||
...getAddressFields(person) | |||
...getAddressOrSameAsMotherFields(person) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to separate this function to two different ones. Often it is perfectly fine to have condition nested inside a function.
When we need to name the function with "or" it might sometimes be better to bring that condition up a level, especially if the condition is "rare".
On high-level, it might be something like this:
const isFather = person === 'father';
// You know better how to name the function and the domain rules.
// Is father only one using the function? Is it always mother? Or can they be other way around? Would be cool if that is either reflected on function name or parameters.
const addressFields = isFather ? getAddressWithSharedResidenceFields(father) : getAddressFields(person)
src/form/v2/person/index.ts
Outdated
@@ -14,6 +14,8 @@ import { field } from '@opencrvs/toolkit/conditionals' | |||
import { getAddressFields } from './address' | |||
import { appendConditionalsToFields, createSelectOptions } from '../utils' | |||
|
|||
export type PersonTypes = 'father' | 'mother' | 'informant' | 'applicant' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use same pattern like this:
export const PersonType = {
father: 'father',
mother: 'mother'
} as const
export type PersonType = keyof typeof PersonType
and use the PersonType.father later in the file, so satisfy wouldn't be needed because they derive from the same source
src/form/v2/person/address.ts
Outdated
@@ -12,6 +12,12 @@ | |||
import { FieldConfig, TranslationConfig } from '@opencrvs/toolkit/events' | |||
import { field } from '@opencrvs/toolkit/conditionals' | |||
import { appendConditionalsToFields, createSelectOptions } from '../utils' | |||
import { PersonTypes } from '.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not matter most of the time if build works, but filename could be added
* chore: update yarn.lock * feat: wip: birth event v2 * feat: use select option in gender, attendantAtBirth and birthType * fix: use number for weight at birth * feat: person input wip * feat: show dob or age based on dobUnknown checkbox * chore: rename directory * amend: import from renamed directory * feat: add informant relation to birth form * feat: render informant fields based on relation to child * feat: separate the logic for concatenating field id * feat: complete informant details apart form person inputs * feat: implement id and address * refactor: create utils * fix: handle undefined values in conditionals * feat: implement father and mother details * feat: implement upload supporting document * fix: use simpler concat * feat: use country field * feat: add place of birth * fix: typo * fix: align label and required properties with legecy birth * fix: font of bulletList * feat: add helper texts * chore: bump up @opencrvs/toolkit * chore: update yarn.lock * feat: use Location type in address * feat: implement urbanOrRural * feat: implement health_failities * feat: add addressInput in tennis-club-membership * fix: update ids of other country input fields * rename: BirthEvent to birthEvent * chore: remove the messages that are not in use * chore: remove unused * refactor: use informantType instead of hardcoding * refactor: birth event * chore: bump up toolkit * feat: add relation to child for someone else * feat: usual place of residence same as mother * refactor: make suggested changes * fix: update types
No description provided.